<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style>

		
		</style>

		<script>
		
			function getInfo(){
				let now = new Date();//表示当前瞬时时间
				console.log(now );
				
				//获取年月日、时分秒 
				// console.log("now.getYear():"+now.getYear())
				// console.log("now.getFullYear():"+now.getFullYear())
				//2020-11-4 15:33:34 
				var  year = now.getFullYear();
				var  month = now.getMonth(); // 从0 开始
				var  date = now.getDate();

				var  hour = now.getHours();
				var  min = now.getMinutes();
				var  secs = now.getSeconds();
				
				var time = year +"-"+(month+1) +"-"+date+" "+hour +":"+min+":"+secs;
				console.log("time: "+time);
				
				// 查找span #time
				let elTime = document.getElementById("time");
				
				
				//设置内容
				 // elTime.innerText = time
				 elTime.innerHTML = "<b>"+time+"</b>" ;//会将 标签进行渲染，
				 // elTime.innerText = "<b>"+time+"</b>"    //认为标签是纯文本直接显示
				
			}
		</script>
	</head>
	<body >
		
		<button type="button" class="mui-btn mui-btn-blue" onclick="getInfo()">获取时间信息</button>
		<div>
			当前时间：<span  id="time"></span>
			
		</div>
		
		
		
	</body>
</html>
